Using Items

Introduction

Items are rigid objects that typically do not move on their own.

Active objects

Items that have the word 'active' in their name are designed to interact with actors; these items can be held or picked up by an actor with the appropriate behavior.

Passive objects

Most items are not active and will remain where they are placed unless moved by some other element, such as by being placed on to a moving vehicle.

Attaching elements to items

Any item can have cameras and/or attractors attached to them. To do this, select the 'Attach Element' dropdown and then select the element you wish to attach.

Texture swap

Any item can be specified as either Standard or Texture swap. This can be done by clicking on Item Settings and selecting the appropriate type.

Texture swap properties

When an item is specified to be texture swap, a set of additional properties must be defined by the user and some external resources (the textures) must be supplied.

Textures Path

This is the path to the directories where the textures are stored. This will point to a directory relative to the application's ApplicationDataPath which by default is in User/csim/data, unless the path is rooted in which case it will be used verbatim.

Framestep

This is the number of frames to display each texture. The Framestep must be set to 1 or more for the textures to begin swapping. A value of 0 will disable the swap function and the item will be displayed with its default set of textures.

Sequence

This is a boolean specifying that the textures must be swapped in sequence, to display like a movie rather than randomly.

Seed

This is the seed value for the randomisation of texture choice.

Organising and setting up textures

The user must supply the textures and place them in an appropriate directory structure. By default, if no Textures Path is supplied, chameleon will look for the textures in the user's Appdata/Roaming/Synthera/Chameleon/data/images directory. This path can be changed by the user and can be different for each texture swap item if desired.

Each set of texture inputs must be stored under its own directory in the destination path, the name of the directory is not important; this directory must contain a file named texture_properties.json plus one directory for each texture input used. These directories must contain exactly one file of the appropriate input type in .jpg or .png format.

Texture properties file format

The texture_properties file contains a dictionary of the format:

Dictionary<string, Tuple<string, string>>

with mapping:
Dictionary<property_name, Tuple<property_value, property_type>>

An example texture_properties.json file:


    {
      "_BaseColorMap": {
        "Item1": "base",
        "Item2": "Texture2D"
      	},
      "_NormalMap": {
    	"Item1": "normal",
    	"Item2": "Texture2D"
  		},
  	"_MaskMap": {
    	"Item1": "map",
    	"Item2": "Texture2D"
  		},
  	"Scale": {
    	"Item1": "0.8,0.8",
    	"Item2": "Float"
  		},
  	"_BaseColor": {
    	"Item1": "#00FF00",
    	"Item2": "Color"
  		}
	}

The location of the texture input for each of the map properties is indicated by the string in 'item1' and the subfolder must be named accordingly. The name of these directories can be anything but it is good practice to name them after the input type they contain, eg: the base (albedo) directory should be called base. The name of the actual texture file itself is not important.

The texture_properties.json file contains a list of properties that with the exception of scale must match the property names of the shader used by the material attached to the item. Supported types are:

Texture2D
Float
Color

Any shader property of one of those types may be changed by referencing its name in the texture_properties.json file and supplying the appropriate value. In the case of a Texture2D the value is the path of the subdirectory where the texture is stored.

The exception is a custom property named 'Scale' which contains a string representation of a comma separated Tuple specifying the desired real world X and Y dimensions of the texture.

Correct behaviour of the Scale property is expected only when the item being textured is a unity primitive whose size is set in the transform.localscale vector.

Scale.X is divided into transform.localscale.x and the result is used to set tiling.x in the material properties.

If transform.localscale.y >= transform.localscale.z then Scale.Y is divided into transform.localscale.y and the result applied to tiling.y, otherwise transform.localscale.z is used instead.

By using this property the user can ensure that any texture appears the same real world size when applied to textures of arbitrary size.

It is not necessary to supply all properties for every (or any) of the textures. For any directory where a property is missing, the previous property value will continue to be used.

Video Textures

There is no specific concept of a video texture. To emulate the look of a video, an image sequence must be created from the video and set up in the same way as any set of textures. With the Sequence boolean set to true, the textures will
be displayed in alphanumeric order as seen in the directory listing. In this case the names of the texture directories are important as they define the display order.

Notes and limitations

Note #1: the textures will swap based on captured images, not displayed images so that if a Framestep of one is specified and the simulation is capturing every third image, then the swap will occur every third displayed image.

Note#2: Demo /interactive mode is not currently supported. Textures will not swap unless the simulation is running and capturing images.

Note#3: While cycling,textures will be chosen at random based on the seed value. To produce a different order of randomisation, choose a different seed value.

TextureSwap functionality is limited to items with only one material. If an item with more than one material is specified as TextureSwap, its behaviour is undefined. Apart from this limitation, any item can be a textureswap item.

The usual considerations of texture mapping apply: flat image or repeating textures work best with flat or otherwise regular geometries while more complicated objects should have textures specifically created and mapped for them.

External assets required

The folder pointed to by the texturesPath property must contain one subfolder for each texture variant.
This subfolder in turn must contain a json file of the format defined above and named texture_properties.json; it must additionally contain a sub folder for each texture input forming a hierarchy as follows:

texture_variant_root 	- texture_variant-1 	- texture_properties.json   
						- base 		- base_texture.png  
						- map		- map_texture.jpg  
						- normal	- normal_texture.png  
			         - texture_variant-2 	   - texture_properties.json  
						- base 		- base_texture.png  
						- map		- map_texture.jpg  
						- normal	- normal_texture.png  

Usage examples

The texture swap functionality can be used to implement a Green screen studio or to create effects such as continuously updating signs or television screens.